package com.jeedcp.core.util;


import org.apache.tomcat.util.codec.binary.Base64;

public class Base64Util {


	/**
	 * 对String类型的数据进行base64加密
	 *
	 */
	public static String encode(String strData) throws Exception {
		byte[] encodeBase64 = Base64.encodeBase64(strData.getBytes("UTF-8"));
		return new String(encodeBase64,"UTF-8");

	}

	public static String decode(String strData) throws Exception {
		byte[] decodeBase64 = Base64.decodeBase64(strData.getBytes("UTF-8"));
		String base64decoded=new String(decodeBase64,"UTF-8");
		return base64decoded;

	}
	public static String encodeThreeTimes(String strData) throws Exception {
		String base64encode = Base64Util.decode(strData);
		base64encode = Base64Util.encode(base64encode);
		base64encode = Base64Util.encode(base64encode);
		return base64encode;

	}
	public static String decodeThreeTimes(String strData) throws Exception {
		String base64decoded = Base64Util.decode(strData);
		base64decoded = Base64Util.decode(base64decoded);
		base64decoded = Base64Util.decode(base64decoded);
		return base64decoded;

	}

//	public  static  void main(String args[]) throws Exception {
//
//		String password="admin" ;
//
//		System.out.println(encodeThreeTimes(password));
//	}


}
